<template>
  <el-form :model="state.form" label-width="120px" class="demo-input-size" >
    <el-form-item label="应用名">
      <el-input v-model="state.form.name"  class="w-50 m-2"/>
      <div>应用程序得名字</div>
    </el-form-item>
    <el-form-item label="域名">
      <el-input v-model="state.form.website" />
    </el-form-item>

    <el-form-item label="小程序AppID">
       <el-input v-model="state.form.app_id" />
    </el-form-item>
    <el-form-item label="小程序Secret">
       <el-input v-model="state.form.secret" />
    </el-form-item>
    <el-form-item label="Token">
       <el-input v-model="state.form.token" />
    </el-form-item>
    <el-form-item label="系统状态">
      <el-radio-group v-model="state.form.status">
        <el-radio label="1">正常运行</el-radio>
        <el-radio label="0">维护中</el-radio>
      </el-radio-group>
    </el-form-item>
  
    <el-form-item>
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script  setup>
import { reactive ,onMounted} from 'vue'
import { ElMessage } from 'element-plus'
import {index,update} from '../../api/config.js'

// do not use same name with ref
const state = reactive({
  form:{}
})
const onSubmit = () => {
  update({configList:state.form}).then(res=>{
    if(res.code == 200) {
      ElMessage({message:"保存成功",type:"success"});
    }
  });
}
onMounted(()=>{
    index().then(res=>{
        if(res.code == 200) {
          state.form = res.data;
        }
    })
});
</script>

<style scoped>
  .demo-input-size{
    width: 500px;
  }
</style>